#!/bin/bash

floders=$(ls ${1})
for floder in $floders
do
    files=$(ls ${1}/${floder}/)
    for file in $files 
    do
        input="${1}/${floder}/${file}"
    
        time1=$(date)
        echo ""	
        echo ${time1}

        lb=`grep "^c pre_LB " $input | cut -d ' ' -f 3`
        k=`grep "^c k " $input | cut -d ' ' -f 3`

        if [ -z "$lb" -a -z "$k" ] 
        then
            echo "input file: $input"
            echo "prework wrong !!!"
        else 
            echo "timeout 12000 ../../../KDefective -r ${input} -O solve -a CPLEX -D Set -k ${k} -M ${lb} -t 10800"
        fi

    done
done

